﻿@namespace BlazorFluentUI
@inherits FluentUIComponentBase
@typeparam TItem

<LocalCS @bind-Rules=@DetailsRowLocalRules />

<div class="rowroot"
     data-selection-index=@ItemIndex
     data-selection-touch-invoke="true"
     data-item-index=@ItemIndex
     aria-rowindex=@(ItemIndex + 1)
     data-automationid="DetailsRow">

    <FocusZone Direction=@FocusZoneDirection.Horizontal
                  AriaLabel=@AriaLabel
                  AriaDescribedBy=@AriaDescribedBy
                  ClassName=@($"fadeIn400 {(Compact ? "is-compact " : "")}{(isSelected ? "is-selected " : "")}{(IsRowHeader ? "is-row-header " : "")}{(IsCheckVisible ? "is-check-visible " : "")}ms-DetailsRow")
                  AllowFocusRoot="true"
                  IsFocusable="true"
                  OnClick=@OnClick >

        @if (showCheckbox)
        {
            <div role="gridcell"
                 aria-colindex="1"
                 data-selection-toggle="true"
                 class="ms-DetailsRow-checkCell"
                 @onclick="args => { }"
                 @onclick:stopPropagation="true">

                <DetailsRowCheck IsVisible=@(this.CheckboxVisibility == CheckboxVisibility.Always)
                                    Compact=@Compact
                                    Checked=@isSelected
                                    UseFastIcons="true"
                                    CanSelect=@canSelect />
            </div>
        }

        <GroupSpacer IndentWidth=@IndentWidth
                        Count=@GroupNestingDepth />

        @if (Item != null)
        {
            <DetailsRowFields Item=@Item
                                 Columns=@Columns
                                 ColumnStartIndex=@((showCheckbox ? 1 : 0)) />

            @if (columnMeasureInfo != null)
            {
                <span role="presentation"
                      class="ms-DetailsRow-cellMeasurer ms-DetailsRow-cell"
                      @ref="cellMeasurer">

                    <DetailsRowFields Item=@Item
                                         Columns=@Columns
                                         ColumnStartIndex=@((showCheckbox ? 1 : 0) + Columns!.Count()) />
                </span>
            }
        }

    <span role="checkbox" class="@($"ms-DetailsRow-checkCover {localCheckCoverRule?.Selector?.SelectorName}")" aria-checked=@isSelected data-selection-toggle="true" />

    </FocusZone>
</div>
